<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>支付药品</title>
    <base th:href="@{http://localhost:9090/}"/>
    <script th:src="@{js/jquery-3.2.1.min.js}"></script>
    <script th:src="@{js/paydrug.js}"></script>
    <script type="text/javascript">
        var countdown = function(timeout) {
            var countUI = document.getElementById("count");
            if(!!countUI) {
                countUI.innerHTML = timeout;
                if (timeout == 0) {
                    alert("支付失败");
                    window.close();
                }
                else {
                    timeout--;
                    setTimeout(function(){
                        countdown(timeout)
                    }, 1000);
                }
            }
        }

        function init(){
            countdown(5);
        }
    </script>
</head>
<body onload=init();>
<div>
    <div>
        <span>倒计时:</span>
        <span id="count">5</span>
        <span>秒</span>
    </div>
    <div>
        <h3 th:text="'支付金额:'+${totalPrice}+'元'" style="text-align: center"></h3>
    </div>
    <div style="text-align: center;">
        <button th:text="立即支付" id="pay" style="margin: 50px"></button>
        <button th:text="取消" id="back" style="margin: 50px"></button>
    </div>
    <input type="hidden" th:value="${totalPrice}" id="totalPrice">
    <input type="hidden" th:value="${session.userSession.id}" id="pId">
    <input type="hidden" id="balance">
</div>
</body>
</html>